package Q2;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[][] arr = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                arr[i][j] = scanner.nextInt();
            }
        }

        int[][] dp = new int[n + 1][n + 1];
        for (int i = 1; i < n + 1; i++) {
            for (int j = 1; j < n + 1; j++) {
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + arr[i - 1][j - 1];
            }
        }

        int ret = Integer.MIN_VALUE;
        for (int i = 0; i < n + 1; i++) {
            for (int j = 0; j < n + 1; j++) {
                for (int k = i + 1; k < n + 1; k++) {
                    for (int l = j + 1; l < n + 1; l++) {
                        ret = Math.max(ret, dp[k][l] - dp[k][j] - dp[i][l] + dp[i][j]);
                    }
                }
            }
        }

        System.out.println(ret);
    }
}
